ComponentOne FlexReport for WinForms
Binding Data to Parameters in Multiple Data Source Report
Working with FlexReport > Data Sources in FlexReport > Connecting to Multiple Data Sources using Code > Binding Data to Parameters in Multiple Data Source Report

Binding data to parameters defines the valid values for the report parameters (elements in the C1FlexReport.Parameters collection). The ReportParameter.AllowedValuesDefinition.Binding.DataSourceName property indicates the data source which is used to build the list of possible values in the parameters. The following code illustrates how to bind data to the parameters in a report with multiple data sources.

' add datasource and parameter using this datasource
Dim mds As DataSource = C1FlexReport.DataSource
Dim ds As New DataSource()
ds.Name = "CategoriesDS"
ds.ConnectionString = mds.ConnectionString
ds.RecordSource = "select * from categories"
ds.DataProvider = DataProvider.OLEDB
C1FlexReport.DataSources.Add(ds)
mds.RecordSource = "select * from products where categoryid = [CategoryParam]"
Dim rp As New ReportParameter()
rp.DataType = Doc.ParameterType.[Integer]
rp.Prompt = "Category"
rp.Name = "CategoryParam"
rp.AllowedValuesDefinition.Binding.DataSourceName = "CategoriesDS"
rp.AllowedValuesDefinition.Binding.ValueExpression = "CategoryID"
rp.AllowedValuesDefinition.Binding.LabelExpression = "CategoryName"
C1FlexReport.Parameters.Add(rp)
// add datasource and parameter using this datasource
DataSource mds = c1FlexReport.DataSource;
DataSource ds = new DataSource();
ds.Name = "CategoriesDS";
ds.ConnectionString = mds.ConnectionString;
ds.RecordSource = "select * from categories";
ds.DataProvider = DataProvider.OLEDB;
c1FlexReport.DataSources.Add(ds);
mds.RecordSource = "select * from products where categoryid = [CategoryParam]";
ReportParameter rp = new ReportParameter();
rp.DataType = Doc.ParameterType.Integer;
rp.Prompt = "Category";
rp.Name = "CategoryParam";
rp.AllowedValuesDefinition.Binding.DataSourceName = "CategoriesDS";
rp.AllowedValuesDefinition.Binding.ValueExpression = "CategoryID";
rp.AllowedValuesDefinition.Binding.LabelExpression = "CategoryName";
c1FlexReport.Parameters.Add(rp);